package com.gitee.wsl.ext.base


import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import org.junit.Test
import kotlin.random.Random

//class LinkTreeUnitTest {
//    val jsonSerializer= Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build()
//
//    val jsonString="""
//        {"name":"TREE_NODE_ROOT_NAME_54651351654613","attentionLevel":0,"childNodes":[{"name":"node_1","attentionLevel":0,"childNodes":[]},{"name":"node_2","attentionLevel":0,"childNodes":[]},{"name":"node_3","attentionLevel":0,"childNodes":[{"name":"node_1","attentionLevel":0,"childNodes":[]}]},{"name":"node_4","attentionLevel":0,"childNodes":[]}]}
//    """.trimIndent()
//
//    @Test
//    fun testTreeBuild(){
//        //val root= createRootNode()
//        //buildTree(root)
//
//        val root=jsonSerializer.adapter(TreeNodeItem::class.java).fromJson(jsonString)
//        println(jsonSerializer.adapter(TreeNodeItem::class.java).toJson(root))
//    }
//
//    private fun buildTree( root: TreeNodeItem){
//        val i= Random.nextInt(5)
//        (1..i).forEach{
//            val node = TreeNodeItem("node_$it")
//            root.addNodeItem(node)
//            if(it%3==0)
//                buildTree(node)
//        }
//    }
//}